//
//  HSYPlayerTimeIndicatorView.m
//  高仿暴走斗图
//
//  Created by key on 16/8/19.
//  Copyright © 2016年 huangsongyao. All rights reserved.
//

#import "HSYPlayerTimeIndicatorView.h"
#import "HSYBaseVideoPlayerView.h"

@interface HSYPlayerTimeIndicatorView ()

@property (nonatomic, strong, readwrite) UIImageView *arrowImageView;
@property (nonatomic, strong, readwrite) UILabel *timeLabel;

@end

@implementation HSYPlayerTimeIndicatorView

- (instancetype)initWithLogo:(UIImage *)logo highLogo:(UIImage *)highLogo
{
    if (self = [super initWithLogo:logo highLogo:highLogo indicatorType:kHSYPlayerIndicatorProgessTypeTimeIndicator]) {

    }
    return self;
}

- (void)toPreventOverlap
{
    //防止重叠
    HSYBaseVideoPlayerView *playerView = (HSYBaseVideoPlayerView *)self.superview;
    playerView.brightnessIndicatorView.hidden = YES;
    playerView.volumeIndicatorView.hidden = YES;
}

- (void)configScreenObserver
{
    CGFloat margin = (kVideoTimeIndicatorViewSide - 24 - 12 - kViewSpacing) / 2;
    self.arrowImageView = [NSObject createImgWithImage:self.logo
                                                hImage:self.logo
                                         clipsToBounds:YES
                                               vcModel:UIViewContentModeScaleToFill];
    self.arrowImageView.frame = CGRectMake((kVideoTimeIndicatorViewSide - 44) / 2, margin, 44, 24);
    [self addSubview:self.arrowImageView];
    
    self.timeLabel = [NSObject createLabelWithText:nil
                                         textColor:[UIColor whiteColor]
                                           bkColor:CLEAR_COLOR
                                              font:HSYFONTSIZE(12)
                                     textAlignment:NSTextAlignmentCenter];
    self.timeLabel.frame = CGRectMake(0, margin + 24 + kViewSpacing, kVideoTimeIndicatorViewSide, 12);
    [self addSubview:self.timeLabel];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    if (self.indiccatorType == kTimeIndicatorPlayStateTypeRewind) {
        [self.arrowImageView setImage:self.logo];
    } else {
        [self.arrowImageView setImage:self.highLogo];
    }
}

- (void)setIndicatorTime:(NSString *)indicatorTime
{
    _indicatorTime = [indicatorTime copy];
    [self updateIndicator:kMinValue];
    self.timeLabel.text = indicatorTime;
}

@end
